package com.ciaojian.core.mapper;

import com.ciaojian.core.model.WorkerFile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 发型师目标 mapper
 *
 * @author Atlakyn
 */
@Mapper
public interface WorkerTurnoverMapper {
    /**
     * 获取发型师月度目标
     *
     * @param workerId  理发师 id
     * @param startDate 开始时间
     * @param endDate   结束时间
     * @return 发型师月度目标
     */
    BigDecimal getTurnover(@Param("workerId") Integer workerId,
                           @Param("startDate") Date startDate,
                           @Param("endDate") Date endDate);


    /**
     * 根据月份和门店查询业绩情况
     *
     * @param month    月份
     * @param workerId 门店Id
     * @return 统计结果
     */
    @Select("SELECT * " +
            "FROM d_worker_turnover dwt " +
            "WHERE dwt.worker_id = #{workerId} " +
            "AND DATE_FORMAT(dwt.date, '%Y-%m') = #{month} ")
    WorkerFile findByMonthAndStore(@Param("month") String month, @Param("workerId") Integer workerId);

}
